package com.pc.ipushpin.business.service.impl;

import com.pc.ipushpin.business.dao.ApiRequestRecordMapper;
import com.pc.ipushpin.business.model.ApiRequestRecord;
import com.pc.ipushpin.business.model.ApiRequestRecordWithBLOBs;
import com.pc.ipushpin.business.service.IApiRequestRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Map;
import java.util.UUID;

@Service("apiRequestRecordService")
public class ApiRequestRecordService implements IApiRequestRecordService {

    @Resource
    private ApiRequestRecordMapper mapper;

    @Override
    public void insertRecord(String module, String method, String version, String terminalType, String requestParams, Map<String, Object> map) {
        ApiRequestRecordWithBLOBs record = new ApiRequestRecordWithBLOBs();
        record.setId(UUID.randomUUID().toString());
        record.setModule(module);
        record.setMethod(method);
        record.setVersion(version);
        record.setTerminalType(terminalType);
        String responseResult = map.toString();
        if(responseResult.contains("wechatName")){
            responseResult ="";
        }
        record.setResponseResult(responseResult);
        mapper.insert(record);
    }

}
